import 'package:daoyi_admin_ui_getx/app/modules/auth/bindings/auth_binding.dart';
import 'package:daoyi_admin_ui_getx/app/modules/auth/controllers/auth_controller.dart';
import 'package:daoyi_admin_ui_getx/app/routes/app_pages.dart';
import 'package:flustars/flustars.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

class AuthMiddleware extends GetMiddleware {

  @override
  RouteSettings? redirect(String? route) {
    if (TextUtil.isEmpty(route)) {
      return super.redirect(route);
    }
    AuthBinding().dependencies();
    if (Get.find<AuthController>().isLogin()) {
      return super.redirect(route);
    }
    return const RouteSettings(
      name: Routes.LOGIN,
    );
  }
}